using System;
using System.Drawing;
using System.ComponentModel;

namespace Camalon.Drawing
{
	[Serializable]
	[TypeConverter(typeof(PointScaleConverter))]
	public struct PointScale
	{
		private float	_x;
		private float	_y;
		
		public PointScale( float x, float y )
		{
			_x				= x;
			_y				= y;
		}


		public PointScale( PointF point )
		{
			_x				= point.X;
			_y				= point.Y;
		}


		public PointScale( PointScale focusScale )
		{
			_x				= focusScale.X;
			_y				= focusScale.Y;

		}

		#region operatoren
		public override bool Equals(object obj)
		{
			if(!( obj is PointScale)) return false;

			return Equals((PointScale)obj);
		}

		public bool Equals(PointScale value)
		{
			return _x == value._x && _y == value._y;
		}

		public override int GetHashCode()
		{
			return _x.GetHashCode()^_y.GetHashCode();
		}

		public static bool operator ==(	PointScale value1,PointScale value2	)
		{
			return value1._x == value2._x && value1._y == value2._y;
		}

		public static bool operator !=(	PointScale value1,PointScale value2	)
		{
			return !(value1== value2);
		}
		#endregion operatoren


		public static PointScale Empty
		{
			get{ return new PointScale(0.0f,0.0f);}
		}

		[Browsable(false)]
		public bool IsEmpty
		{
			get{ return _x == 0.0f && _y == 0.0f;}
		}


		public static PointScale Center
		{
			get{ return new PointScale(0.5f,0.5f);}
		}

		[Browsable(false)]
		public bool IsCenter
		{
			get{ return _x == 0.5f && _y == 0.5f;}
		}



		public static PointScale Identity
		{
			get{ return new PointScale(1.0f,1.0f);}
		}

		[Browsable(false)]
		public bool IsIdentity
		{
			get{ return _x == 1.0f && _y == 1.0f;}
		}



		[DefaultValue( 0.5f )]
		[TypeConverter(typeof(PercentConverter))]
		[RefreshProperties( RefreshProperties.All)]
		public float X
		{
			get{ return _x;  }
			set
			{ 
				_x = value;
			}
		}


		[DefaultValue( 0.5f )]
		[TypeConverter(typeof(PercentConverter))]
		[RefreshProperties( RefreshProperties.All)]
		public float Y
		{
			get{ return _y;  }
			set
			{ 
				_y = value;
			}
		}


		[Browsable( false)]
		public PointF Point
		{
			get{ return new PointF(_x,_y);}
		}


	}



}
